<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.min.js"></script>
</head>

<body>
    <div id='app'>
        <router-view></router-view>

    </div>
    <template id="demo">
        <div>
            <button @click="chage">js跳转</button>
        </div>
    </template>
    <template id="login2">
        <div>
           我是被跳转的
        </div>
    </template>
    <script>
        let login = {
            template: "#demo",
            methods: {
                chage() {
                    console.log(4545);
                    this.$router.push("/login")
                }
            },
        } 
        let login2 = {
            template: "#login2",
            // methods: {
            //     chage() {
            //         console.log(4545);
            //         this.$router.push("/login")
            //     }
            // },
        } 
    </script>
    <script>



        let router = new VueRouter({
            routes: [
                {
                    path: "/",
                    component: login
                },
                {
                    path: "/login",
                    component: login2
                }
            ]
        })


        const vm = new Vue({
            el: '#app',
            data: {
            },

            router
        })
    </script>
</body>

</html>